// AUTO GENERATED CODE!
// CODE GENERATOR WILL NOT PRESERVE MANUAL CHANGES TO THIS CODE!
// 

// MIT License (MIT)
// 
// Copyright (c) 2014 K Ercan Turkarslan
// 
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
// 
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
// 
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
// 


using System;

namespace Mios.Generated.ServiceFiles
{
    // Generated from S_VSwitch.xml
    
    public class VSwitchService : MiosService
    {
        #region Target : Boolean;
        private Boolean? _mTarget;
        
        public Boolean Target
        {
            get
            {
                return _mTarget ?? GetTarget();
            }
        }
        
        #region Action SetTarget(Boolean newTargetValue) : String;
        public String SetTarget(Boolean newTargetValue)
        {
            return Engine.Luup_CallAction(base.DeviceId, base.ServiceId, "SetTarget",
                String.Format("newTargetValue={0}", ToLuup(_mTarget = newTargetValue)));
        }
        #endregion Action SetTarget
        
        #region Action GetTarget() : Boolean;
        public Boolean GetTarget()
        {
            _mTarget = FromLuupBoolean(Engine.Luup_VariableGet(base.DeviceId, base.ServiceId, "Target"));
            
            return _mTarget.Value;
        }
        #endregion Action GetTarget
        
        #endregion
        
        #region Status : Boolean;
        private Boolean? _mStatus;
        
        public Boolean Status
        {
            get
            {
                return _mStatus ?? GetStatus();
            }
        }
        
        #region Action GetStatus() : Boolean;
        public Boolean GetStatus()
        {
            _mStatus = FromLuupBoolean(Engine.Luup_VariableGet(base.DeviceId, base.ServiceId, "Status"));
            
            return _mStatus.Value;
        }
        #endregion Action GetStatus
        
        #endregion
        
        #region Text1 : String;
        private String _mText1;
        
        public String Text1
        {
            get
            {
                return _mText1 ?? GetText1();
            }
        }
        
        #region Action SetText1(String newText1Value) : String;
        public String SetText1(String newText1Value)
        {
            if (String.IsNullOrEmpty(newText1Value))
                throw new ArgumentNullException("newText1Value");
            
            return Engine.Luup_CallAction(base.DeviceId, base.ServiceId, "SetText1",
                String.Format("newText1Value={0}", ToLuup(_mText1 = newText1Value)));
        }
        #endregion Action SetText1
        
        #region Action GetText1() : String;
        public String GetText1()
        {
            _mText1 = FromLuupString(Engine.Luup_VariableGet(base.DeviceId, base.ServiceId, "Text1"));
            
            return _mText1;
        }
        #endregion Action GetText1
        
        #endregion
        
        #region Text2 : String;
        private String _mText2;
        
        public String Text2
        {
            get
            {
                return _mText2 ?? GetText2();
            }
        }
        
        #region Action SetText2(String newText2Value) : String;
        public String SetText2(String newText2Value)
        {
            if (String.IsNullOrEmpty(newText2Value))
                throw new ArgumentNullException("newText2Value");
            
            return Engine.Luup_CallAction(base.DeviceId, base.ServiceId, "SetText2",
                String.Format("newText2Value={0}", ToLuup(_mText2 = newText2Value)));
        }
        #endregion Action SetText2
        
        #region Action GetText2() : String;
        public String GetText2()
        {
            _mText2 = FromLuupString(Engine.Luup_VariableGet(base.DeviceId, base.ServiceId, "Text2"));
            
            return _mText2;
        }
        #endregion Action GetText2
        
        #endregion
        
        
        #region Action ToggleState()
        public void ToggleState()
        {
            Engine.Luup_CallAction(base.DeviceId, base.ServiceId, "ToggleState");
        }
        #endregion Action ToggleState
        
        
        #region Method SetVariable(String name, String value) : Boolean;
        internal override Boolean SetVariable(String name, String value)
        {
            switch(name)
            {
                case "Status":
                    _mStatus = FromLuupBoolean(value); return true;
                case "Target":
                    _mTarget = FromLuupBoolean(value); return true;
                case "Text1":
                    _mText1 = FromLuupString(value); return true;
                case "Text2":
                    _mText2 = FromLuupString(value); return true;
                default:
                    return false;
            }
        }
        #endregion Method SetVariable
        
        public VSwitchService(MiosEngine engine, UInt32 deviceId, String serviceId)
            : base(engine, deviceId, serviceId)
        {
            
        } //End Constructor
    } //End of class
} //End of Namespace

